package com.lc.common.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;

/**
 * Cron表达式工具类
 *
 * @author YanHuan
 */
public class CronUtil {

    private CronUtil() {
        throw new IllegalStateException("util class");
    }

    /**
     * 功能描述：localDateTime转换cron表达式
     *
     * @param localDateTime 日期时间
     * @return cron表达式
     */
    public static String formatLocalDateTimeByPattern(LocalDateTime localDateTime) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("ss mm HH dd MM ? yyyy");
        String formatTimeStr = null;
        if (Objects.nonNull(localDateTime)) {
            formatTimeStr = localDateTime.format(dateTimeFormatter);
        }
        return formatTimeStr;
    }


}
